From ad19a31d9b4230cfb87780e1b50ef71ce4aa8240 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 25 Jun 2014 16:31:57 -0700 Subject: [PATCH] Prepare for buildbot automation * The installation script was modified to recognize when its running on windows, as well as tweaking how it downloads and installs snapshots. The goal here was to make the script runnable on buildbot for mac/linux/windows with 32/64 bit options on mac/linux. * The installation script now install rustc to `rustc/bin` in the local directory to have parallel builds on buildbot. * The tests now store all their temporary state locally in the build directory to enable parallel builds on buildbot. * A shell test is ignored which assumed the presence of a TTY output. --- .travis.install.deps.sh | 55 +++++++++++++------ .travis.yml | 11 ++-- Makefile | 21 +++++-- libs/hammer.rs | 2 +- libs/toml-rs | 2 +- .../check-style.sh | 0 tests/support/paths.rs | 5 +- tests/test_cargo_compile_path_deps.rs | 2 +- tests/test_shell.rs | 8 +-- 9 files changed, 69 insertions(+), 37 deletions(-) rename .travis.check.style.sh => tests/check-style.sh (100%) diff --git a/.travis.install.deps.sh b/.travis.install.deps.sh index 39750a392..ff4f5007e 100755 --- a/.travis.install.deps.sh +++ b/.travis.install.deps.sh @@ -1,29 +1,50 @@ -set -ex +set -x -if [ "${TRAVIS_OS_NAME}" = "osx" ]; then +if [ "${TRAVIS_OS_NAME}" = "osx" ] || [ "${PLATFORM}" = "mac" ]; then target=apple-darwin -else +elif [ "${TRAVIS_OS_NAME}" = "linux" ] || [ "${PLATFORM}" = "linux" ]; then + target=unknown-linux-gnu +elif [ "${OS}" = "Windows_NT" ] || [ "${PLATFORM}" = "win" ]; then + target=pc-mingw32 + windows=1 +fi + +if [ "${TRAVIS}" = "true" ] && [ "${target}" = "unknown-linux-gnu" ]; then # Install a 32-bit compiler for linux sudo apt-get update - sudo apt-get install gcc-multilib - target=unknown-linux-gnu + sudo apt-get install gcc-multilib lib32stdc++6 fi # Install both 64 and 32 bit libraries. Apparently travis barfs if you try to # just install the right ones? This should enable cross compilation in the # future anyway. -curl -O http://static.rust-lang.org/dist/rust-nightly-x86_64-$target.tar.gz -curl -O http://static.rust-lang.org/dist/rust-nightly-i686-$target.tar.gz -tar xfz rust-nightly-x86_64-$target.tar.gz -tar xfz rust-nightly-i686-$target.tar.gz -cp -r rust-nightly-i686-$target/lib/rustlib/i686-$target \ - rust-nightly-x86_64-$target/lib/rustlib -(cd rust-nightly-x86_64-$target && \ - find lib/rustlib/i686-$target/lib -type f >> \ - lib/rustlib/manifest.in) -sudo ./rust-nightly-x86_64-$target/install.sh +if [ -z "${windows}" ]; then + curl -O http://static.rust-lang.org/dist/rust-nightly-i686-$target.tar.gz + tar xfz rust-nightly-i686-$target.tar.gz + curl -O http://static.rust-lang.org/dist/rust-nightly-x86_64-$target.tar.gz + tar xfz rust-nightly-x86_64-$target.tar.gz -export RUSTC="rustc --target=${ARCH}-${target}" + if [ "${BITS}" = "32" ]; then + src=x86_64 + dst=i686 + else + src=i686 + dst=x86_64 + fi + cp -r rust-nightly-$src-$target/lib/rustlib/$src-$target \ + rust-nightly-$dst-$target/lib/rustlib + (cd rust-nightly-$dst-$target && \ + find lib/rustlib/$src-$target/lib -type f >> \ + lib/rustlib/manifest.in) -set +ex + ./rust-nightly-$dst-$target/install.sh --prefix=rustc + rm -rf rust-nightly-$src-$target + rm -rf rust-nightly-$dst-$target +else + rm -rf *.exe rustc + curl -O http://static.rust-lang.org/dist/rust-nightly-install.exe + innounp -y -x rust-nightly-install.exe + mv '{app}' rustc +fi +set +x diff --git a/.travis.yml b/.travis.yml index b921ca20d..273749079 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,16 @@ language: rust install: - - . ./.travis.install.deps.sh + - sh ./.travis.install.deps.sh script: - - ./.travis.check.style.sh - - make CC="$CC" RUSTC="$RUSTC" -j4 - - make CC="$CC" RUSTC="$RUSTC" test -j4 + - make + - make test -j4 - make install DESTDIR=${PWD}/destdir env: - - ARCH=i686 CC='cc -m32' - - ARCH=x86_64 CC=cc + - BITS=32 + - BITS=64 os: - linux diff --git a/Makefile b/Makefile index 2e852de1f..26ea4224d 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,16 @@ -RUSTC ?= rustc RUSTC_FLAGS ?= DESTDIR ?= PREFIX ?= /usr/local BINDIR ?= $(PREFIX)/bin +ifeq ($(wildcard rustc/bin),) +export RUSTC := rustc +else +export RUSTC := $(CURDIR)/rustc/bin/rustc +endif + +export PATH := $(PATH):$(CURDIR)/rustc/bin + # Link flags to pull in dependencies BINS = cargo \ cargo-build \ @@ -15,8 +22,8 @@ BINS = cargo \ SRC = $(shell find src -name '*.rs' -not -path 'src/bin*') DEPS = -L libs/hammer.rs/target -L libs/toml-rs/build -TOML = libs/toml-rs/build/$(shell rustc --crate-file-name libs/toml-rs/src/toml.rs) -HAMMER = libs/hammer.rs/target/$(shell rustc --crate-type=lib --crate-file-name libs/hammer.rs/src/hammer.rs) +TOML = libs/toml-rs/build/$(shell $(RUSTC) --crate-file-name libs/toml-rs/src/toml.rs) +HAMMER = libs/hammer.rs/target/$(shell $(RUSTC) --crate-type=lib --crate-file-name libs/hammer.rs/src/hammer.rs) HAMCREST = libs/hamcrest-rust/target/libhamcrest.timestamp LIBCARGO = target/libcargo.timestamp BIN_TARGETS = $(patsubst %,target/%,$(BINS)) @@ -66,7 +73,10 @@ test-unit: target/tests/test-unit test-integration: target/tests/test-integration $< $(only) -test: test-unit test-integration +test: test-unit test-integration style + +style: + sh tests/check-style.sh clean: rm -rf target @@ -81,8 +91,9 @@ install: install target/cargo target/cargo-* $(DESTDIR)$(BINDIR) # Setup phony tasks -.PHONY: all clean distclean test test-unit test-integration libcargo +.PHONY: all clean distclean test test-unit test-integration libcargo style # Disable unnecessary built-in rules .SUFFIXES: + diff --git a/libs/hammer.rs b/libs/hammer.rs index 0baf235e2..d2467aa7a 160000 --- a/libs/hammer.rs +++ b/libs/hammer.rs @@ -1 +1 @@ -Subproject commit 0baf235e24d6c3e20f3ae8368d1c0fce08138bd4 +Subproject commit d2467aa7a6da51945bce72c3ede891d00b11c78f diff --git a/libs/toml-rs b/libs/toml-rs index 66c83483f..7ba80c5ac 160000 --- a/libs/toml-rs +++ b/libs/toml-rs @@ -1 +1 @@ -Subproject commit 66c83483f880c87e44c57617bec2615e945cce14 +Subproject commit 7ba80c5ac4a3f6bc3801bb4ac86fd65a569a07ba diff --git a/.travis.check.style.sh b/tests/check-style.sh similarity index 100% rename from .travis.check.style.sh rename to tests/check-style.sh diff --git a/tests/support/paths.rs b/tests/support/paths.rs index 99de20a22..5dc6c86c3 100644 --- a/tests/support/paths.rs +++ b/tests/support/paths.rs @@ -13,8 +13,9 @@ static mut NEXT_ID: atomics::AtomicUint = atomics::INIT_ATOMIC_UINT; pub fn root() -> Path { let my_id = *task_id.get().unwrap(); - let path = os::tmpdir().join(CARGO_INTEGRATION_TEST_DIR) - .join(format!("test-{}", my_id)); + let path = os::self_exe_path().unwrap() + .join(CARGO_INTEGRATION_TEST_DIR) + .join(format!("test-{}", my_id)); realpath(&path).unwrap() } diff --git a/tests/test_cargo_compile_path_deps.rs b/tests/test_cargo_compile_path_deps.rs index 635808eb1..d502da4da 100644 --- a/tests/test_cargo_compile_path_deps.rs +++ b/tests/test_cargo_compile_path_deps.rs @@ -350,7 +350,7 @@ test!(nested_deps_recompile { "#).assert(); // This shouldn't recompile `bar` - assert_that(p.process("cargo-build"), + assert_that(p.process(cargo_dir().join("cargo-build")), execs().with_stdout(format!("{} bar v0.5.0 (file:{})\n\ {} foo v0.5.0 (file:{})\n", FRESH, bar.display(), diff --git a/tests/test_shell.rs b/tests/test_shell.rs index df730a214..aa6d6bb07 100644 --- a/tests/test_shell.rs +++ b/tests/test_shell.rs @@ -1,7 +1,3 @@ -#![cfg(not(windows))] // getting the actual colored output is a little different - // on windows, so it's tough to get a reference copy of all - // the color - use support::{ResultTest,Tap,shell_writes}; use hamcrest::{assert_that}; use std::io::{MemWriter, BufWriter, IoResult}; @@ -37,6 +33,10 @@ test!(color_explicitly_disabled { }) test!(colored_shell { + let term: Option> = + Terminal::new(MemWriter::new()); + if term.is_none() { return } + let config = ShellConfig { color: true, verbose: true, tty: true }; let mut buf: Vec = Vec::from_elem(100, 0 as u8); -- 2.30.2